package test.h0815;

import java.util.*;
/**
  * @description 分配土地
  * @author 不知名帅哥
  * @date 2024/8/15 15:57
  * @version 1.0
*/
public class Main5 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int m = sc.nextInt(); //长
        int n=sc.nextInt();  //宽
        int[][] land = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                land[i][j]=sc.nextInt();
            }
        }

        int res=getResult(land);
        System.out.println(res);
    }

    private static int getResult(int[][] land) {
        HashMap<Integer, List<int[]>> map = new HashMap<>();
        for (int i = 0; i < land.length; i++) {
            for (int j = 0; j < land[0].length; j++) {
                if (land[i][j]!=0){
                    List<int[]> orDefault = map.getOrDefault(land[i][j], new ArrayList<>());
                    orDefault.add(new int[]{i,j});
                    map.put(land[i][j], orDefault);
                }
            }
        }
        int area=0;
        for (Integer key : map.keySet()) {
            List<int[]> list = map.get(key);
            if (list.size()==1){
                //只有一个点，面积为一
                area=1;
            }else {
                //计算面积
                area=Math.max(calculateArea(list),area);
            }
        }
        return area;
    }

    private static int calculateArea(List<int[]> list) {
        //求出边界
        int n = list.size();
        int[] posX = new int[n];
        int[] posY=new int[n];
        for (int i = 0; i < n; i++) {
            int[] arr = list.get(i);
            posX[i]=arr[0];
            posY[i]=arr[1];
        }
        Arrays.sort(posX);
        Arrays.sort(posY);
        int x1=posX[0];
        int x2=posX[n-1];
        int y1 = posY[0];
        int y2 = posY[n - 1];
        return (x2-x1+1)*(y2-y1+1);
    }
}
